package com.erli.exchange.common.sg.mapper;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.erli.exchange.core.util.JAXBUtil;

import lombok.Setter;

//<resultMap id="BaseResultMap" type="com.anban.sso.api.dao.entity.DBDatabaseEntity">
@Setter
@XmlRootElement(name="resultMap")
public class ResultMap {

	@XmlAttribute
	private String id;
	
	@XmlAttribute
	private String type;
	
	@XmlElement(name="id")
	private ResultMapId resultMapId;
	
	@XmlElement(name="result")
	private List<ResultMapResult> resultMapResultList;
	
	
	public static void main(String[] args) throws Exception {
		ResultMap resultMap = new ResultMap();
		ResultMapId resultMapId = new ResultMapId();
		List<ResultMapResult> resultMapResultList = new ArrayList<ResultMapResult>();
		//<result column="update_user_id" jdbcType="INTEGER" property="updateUserId" />
		ResultMapResult resultMapResult1 = new ResultMapResult();
		resultMapResult1.setColumn("update_user_id");
		resultMapResult1.setJdbcType("INTEGER");
		resultMapResult1.setProperty("updateUserId");
		ResultMapResult resultMapResult2 = new ResultMapResult();
		resultMapResult2.setColumn("update_time");
		resultMapResult2.setJdbcType("datetime");
		resultMapResult2.setProperty("updateTime");
		
		resultMapResultList.add(resultMapResult1);
		resultMapResultList.add(resultMapResult2);
		
		resultMapId.setColumn("id");
		resultMapId.setJdbcType("INTEGER");
		resultMapId.setProperty("id");
		resultMap.setResultMapId(resultMapId);
		resultMap.setResultMapResultList(resultMapResultList);
		
		resultMap.setId("BaseResultMap");
		resultMap.setType("com.anban.sso.api.dao.entity.DBDatabaseEntity");
		
		System.out.println(JAXBUtil.toXML(resultMap));
	}
}
